#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void getFZFM(char data[], int* FZ, int* FM)
{
	int num = 0;
	for(int i = 0, j = 0; i < strlen(data); i++){
		if(data[i] == '/'){
			j = 0;
			*FZ = num;
			num = 0;
		}
		num = num * 10 * j + (data[i] - '0');
	}
	*FM = num;
}

int getGCD(int a, int b)
{
	while(b){
		int temp = a % b;
		a = b;
		b = temp;
	}
	return a;
}

void print(int FZ, int FM)
{
	if(FM == 0){
		printf("Inf");
		return;
	}
	//输出指定格式
	int num = FZ / FM;
	int gcd = 0;
	if(num > 0) {
		FZ = FZ - num * FM;
		gcd = getGCD(FZ, FM);
		printf("%d %d/%d ", num, FZ/gcd, FM/gcd);
	}else if(FZ % FM == 0){
		gcd = getGCD(FZ, FM);
		if(FZ < 0){
			printf("(%d)", FZ/gcd);	
		}else{
			printf("%d", FZ/gcd);
		}
	}else if(num < 0){
		FZ = FZ - num * FM;
		gcd = getGCD(FZ, FM);
		printf("(%d %d/%d) ", num, abs(FZ/gcd), abs(FM/gcd));
	}else{
		gcd = getGCD(FZ, FM);
		if(FZ*FM < 0){
			printf("(%d/%d)", -1*abs(FZ/gcd), abs(FM/gcd));
		}else{
			printf("%d/%d ", FZ/gcd, FM/gcd);
		}
	}
}

int main(){
	char N1[1000] = {0}, N2[1000] = {0};
	int FZ1 = 0, FM1 = 0;
	int FZ2 = 0, FM2 = 0;

	scanf("%s %s", &N1, &N2);

	getFZFM(N1, &FZ1, &FM1);

	getFZFM(N2, &FZ2, &FM2);
	if(N2[0] == '-'){
		FZ2 *= -1;
	}
	//输出+-*/
	
	//+
	print(FZ1, FM1);
	printf("+ ");
	print(FZ2, FM2);	
	printf(" = ");
	print((FZ1 * FM2 + FZ2 * FM1), (FM1 * FM2));
	printf("\n");
	//-
	print(FZ1, FM1);
	printf("- ");
	print(FZ2, FM2);	
	printf(" = ");
	print((FZ1 * FM2 - FZ2 * FM1), (FM1 * FM2));
	printf("\n");
	//*
	print(FZ1, FM1);
	printf("* ");
	print(FZ2, FM2);	
	printf(" = ");
	print((FZ1 * FZ2), (FM1 * FM2));
	printf("\n");
	//  /
	print(FZ1, FM1);
	printf("/ ");
	print(FZ2, FM2);	
	printf(" = ");
	print((FZ1 * FM2), (FM1 * FZ2));
	printf("\n");
	return 0;
}
